<template>
  <!-- 模块1 -->
  <div class="modular">
    <div class="modular_top">
      <div class="triangle"></div>
      <div class="modular_icon">
        <img src="@/assets/img/泵房信息@2x.png" alt="">
      </div>
      <h2>泵房信息 <span>（恒生科技园36号楼）</span></h2>
    </div>
    <div class="house_cont">
      <div class="house_top">
        <div class="title">
          <h2>{{ this.data.site_name }} <span>(YT000001)</span></h2>
          <div class="use">
            <h3>使用中</h3>
          </div>
        </div>
        <div class="position">
          <img src="@/assets/img/位置@2x.png" alt="">
          <span>{{ this.data.install_address }}</span>
        </div>
        <div class="line"></div>
      </div>
      <div class="house_center_cont">
        <div class="house_left">
          <div class="house_left_icon">
            <!-- <img src="@/assets/img/YT.gif" alt=""> -->
            <img v-show="siteId == 1" src="@/assets/img/YT.gif" alt="">
            <img v-show="siteId == 2" src="@/assets/img/XHW.gif" alt="">
          </div>
        </div>
        <div class="house_right">
          <div class="house_text">
            <div class="item">泵房类型 ：<span>{{ this.data.site_type }}</span></div>
            <div class="item">厂家类型 ：<span>{{ this.data.manufactor_type }}</span></div>
            <div class="item">设备类型 ：<span>{{ this.data.device_type }}</span></div>
            <div class="item">投运时间 ：<span>{{ this.data.built_date }}</span></div>
            <div class="item">泵房面积 ：<span>{{ this.data.acreage }}m3</span></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import * as api from '@/assets/utils/api.js'
export default {
  data() {
    return {
      myChart: {},
      data: [],
      siteId: 1,
    }
  },
  async created() {
    this.getData(this.siteId)
  },
  methods: {
    changeData(value) {
      this.siteId = value
      this.getData(Number(value))
    },
    async getData(idNum) {
      // 接口参数
      const id = { tenantid: 1128, siteId: idNum }
      const res = await api.house(id)
      this.data = res.data[0]
      this.data.built_date = this.transformTimestamp(this.data.built_date)
    },
    transformTimestamp(timestamp) {
      let a = new Date(timestamp).getTime()
      const date = new Date(a)
      const Y = date.getFullYear() + '-'
      const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
      const D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '  '
      // const h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
      // const m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes())
      // const s = date.getSeconds(); // 秒
      // const dateString = Y + M + D + h + m
      const dateString = Y + M + D
      // console.log('dateString', dateString); // > dateString 2021-07-06 14:23
      return dateString
    }
  }
}
</script>

<style lang="scss" scoped>
.modular {

  .house_cont {
    display: flex;
    flex-direction: column;
    padding: .46rem .21rem 0 .21rem;

    .house_top {
      width: 100%;
      position: relative;

      .title {
        display: flex;
        justify-content: space-between;

        h2 {
          color: #fff;
          font-size: 0.22rem;
          font-family: "Pang";
          letter-spacing: 0.055rem;
          white-space: nowrap;

          span {
            font-size: 0.18rem;
            letter-spacing: 0;
            margin-left: -5px;
          }
        }

      }

      .use {
        width: .62rem;
        height: .2rem;
        background: rgba(255, 76, 75, 0.2);
        border: 1px solid #FF4C4B;
        // border-image: linear-gradient(-27deg, #FF4C4B, #FF6A6B) 10 10;
        border-radius: 10px;
        margin-top: .14rem;
        position: absolute;
        right: 0;
        top: -0.1rem;

        h3 {
          font-size: 0.12rem;
          color: #FD5E5D;
          text-align: center;
          line-height: .2rem;
        }
      }

      .position {
        display: flex;
        padding: 0.05rem 0;

        img {
          width: 0.14rem;
          height: 0.14rem;
          margin: 0 5px 0 8px;
        }

        span {
          font-size: .14rem;
          color: #CCDDFF;
        }
      }

      .line {
        width: 100%;
        height: 1px;
        background-color: #5fa1ff;
        opacity: 0.6;
        margin-top: 0.07rem;
        position: relative;

        &::after {
          content: "";
          width: 96%;
          height: 1px;
          background: #2b518a;
          position: absolute;
          left: 2%;
          top: 0;
        }
      }
    }

    .house_center_cont {
      display: flex;
      justify-content: space-between;
      margin-top: 0.25rem;

      .house_left {
        width: 59%;

        .house_left_icon {
          width: 100%;
          display: flex;
          justify-content: center;
          align-items: center;

          img {
            width: 80%;
          }
        }
      }

      .house_right {
        width: 35%;
        position: relative;

        .house_text {
          display: flex;
          flex-direction: column;

          .item {
            // width: 33.3%;
            display: flex;
            font-size: 0.12rem;
            color: #fff;
            margin-bottom: 0.14rem;
            white-space: nowrap;

            span {
              color: #17E8FF;
            }

            .max {
              color: #fff;
              letter-spacing: 0.05rem;
            }
          }
        }
      }
    }

  }
}
</style>